<div class="page" style="min-height: 500px;">
  <div class="page-container">
    <div class="container">
      <div class="row">
        <div class="span3">
          <h4 class="header">Tweets</h4>
          <div class="sidebar">
            <ul class="col-nav span3">
              <li <?php if ($type == '' || $type == 'active') { ?> style="background-color: #EEE;" <?php } ?>><a href="<?php echo base_url('tweets/active'); ?>"><i class="pull-right icon-calendar"></i>Active tweets</a></li>
              <li <?php if ($type == 'new') { ?> style="background-color: #EEE;" <?php } ?>>
                <a href="<?php echo base_url('tweets/new'); ?>">
                  <i class="pull-right icon-cog"></i>
                  <?php if (!empty($all_tweet_extras['new_tweets_count'])) { ?>
                    <span title="<?php echo $all_tweet_extras['new_tweets_count']; ?> New tweets" class="label label-inverse pull-right" style="margin-right: 10px;"><?php echo $all_tweet_extras['new_tweets_count']; ?></span>
                  <?php } ?>
                  New tweets
                </a>
              </li>
              <li <?php if ($type == 'top') { ?> style="background-color: #EEE;" <?php } ?>><a href="<?php echo base_url('tweets/top'); ?>"><i class="pull-right icon-star"></i>Top tweets</a></li>
              <li <?php if ($type == 'my') { ?> style="background-color: #EEE;" <?php } ?>><a href="<?php echo base_url('tweets/my'); ?>"><i class="pull-right icon-user"></i>My tweets</a></li>
            </ul>
          </div>

          <?php if (!empty($non_users)) { ?>
            <div class="clearfix"></div>
            <div class="filters">
              <h5><a style="text-decoration: none; color: #555; font-weight: bold;">Special Zone</a></h5>
              <?php foreach ($non_users as $non_user) { ?>
                <span class="pull-right"></span>
                <label for="cb3"><a style="text-decoration: none; cursor: pointer;" href="<?php echo site_url('tweets/search?search_term=@' . $non_user['user_name']); ?>" title="@<?php echo $non_user['user_name']; ?>"><?php echo $non_user['user_display_name']; ?></a></label>
              <?php } ?>
            </div>
          <?php } ?>

          <div class="clearfix"></div>
          <div class="filters">
            <h5><a style="text-decoration: none; color: #555; font-weight: bold;">Counter</a></h5>
            <?php if (!empty($all_tweet_extras)) { ?>
              <span class="pull-right"><?php echo $all_tweet_extras['tweet_total_count']; ?></span>
              <label for="cb3">Total Tweets</label>
              <span class="pull-right"><?php echo $all_tweet_extras['tweet_total_replies_count']; ?></span>
              <label for="cb3">Total Replies</label>
              <span class="pull-right"><?php echo $all_tweet_extras['my_tweet_total_count']; ?></span>
              <label for="cb3">My Total Tweets</label>
              <span class="pull-right"><?php echo $all_tweet_extras['tweet_my_replies_count']; ?></span>
              <label for="cb3">My Total Replies</label>
            <?php } ?>
            <h5><a style="text-decoration: none; color: #555; font-weight: bold;">Top 10</a></h5>
            <?php if (!empty($all_tweet_users)) { ?>
              <?php foreach ($all_tweet_users as $all_tweet_user) { ?>
                <span class="pull-right"><?php echo ($all_tweet_user['user_replies_count'] + $all_tweet_user['user_tweets_count']); ?></span>
                <label for="cb5">
                  <?php if (is_online($all_tweet_user['user_id'])) { ?>
                    <img src="<?php echo site_url('assets/img/online_button_tiny.png'); ?>" title="Online"/>
                  <?php } else { ?>
                    <img src="<?php echo site_url('assets/img/offline_button_tiny.png'); ?>" title="Offline"/>
                  <?php } ?>
                  <a title="<?php echo '@' . $all_tweet_user['user_name']; ?>" style="text-decoration: none; color: #333;" href="<?php echo base_url('profile/' . $all_tweet_user['user_name']); ?>"><?php echo $all_tweet_user['user_display_name']; ?></a>
                </label>
              <?php } ?>
            <?php } ?>
          </div>
        </div>
        <div class="span9">
          <div class="pull-right">
            <form method="get" action="<?php echo base_url('tweets/search'); ?>">
              <input type="text" name="search_term" value="<?php echo $search_term; ?>" placeholder="Search Tweets" style="margin-bottom: 0px;" required="required" maxlength="100">
              <button title="Search" class="btn" type="submit"><i class="icon-search"></i></button>
              <a class="btn" href="<?php echo base_url('tweet/create'); ?>">Create Tweet</a>
            </form>
          </div>
          <h4 class="header"><?php echo ucfirst($type); ?> Tweets</h4>
          <div class="stream">
            <?php if (!empty($tweets)) { ?>
              <?php foreach ($tweets as $tweet) { ?>
                <div class="item">
                  <a href="<?php echo base_url('profile/' . $tweet['user_name']); ?>"><img title="<?php echo $tweet['user_display_name']; ?>" src="<?php echo base_url('assets/photos/' . $tweet['user_image']); ?>" class="avatar"/></a>
                  <p class="date"><?php echo date('d - M - Y', strtotime($tweet['tweet_date'])); ?></p>
                  <h4><a style="text-decoration: none; word-break: break-all;" href="<?php echo base_url('tweet/' . $tweet['tweet_id']); ?>" title="<?php echo $tweet['tweet_subject']; ?>"><?php echo mb_substr($tweet['tweet_subject'], 0, 100) . '...'; ?></a></h4>
                  <div class="row">
                    <?php $tweet_body = mb_substr((strip_tags($tweet['tweet_message'])), 0, 150); ?>
                    <?php if (!empty($tweet_body)) { ?>
                      <p class="span8" style="word-break: normal;"><?php echo $tweet_body . '...'; ?></p>
                    <?php } else { ?>
                      <p class="span8" style="word-break: normal;">< Image, Link, Etc> ...</p>
                    <?php } ?>
                  </div>
                  <?php $get_user_like_status = get_user_like_status('tweet', $tweet['tweet_id']); ?>
                  <p class="date" style="float: left; margin-top: -3px; color: #555;">
                    <span title="<?php echo $tweet['tweet_replies_count']; ?> replies" style="cursor: pointer;"><i class="icon-comment"></i>&nbsp;:&nbsp;<?php echo $tweet['tweet_replies_count']; ?></span>&nbsp;|&nbsp;
                    <span title="<?php echo $get_user_like_status['total_count']; ?> likes" style="cursor: pointer;"><i class="icon-heart"></i>&nbsp;:&nbsp;<?php echo $get_user_like_status['total_count']; ?></span>&nbsp;|&nbsp;
                    <span title="<?php echo '@' . $tweet['user_name']; ?> started this tweet" style="cursor: pointer;"><i class="icon-user"></i>&nbsp;:&nbsp;<?php echo '@' . $tweet['user_name']; ?></span>
                  </p>
                </div>
              <?php } ?>
              <div id="old_tweets"></div>
              <div id="load_more"></div>
              <?php if ($tweets_count > $tweet_limit) { ?>
                <div class="clearfix" style="height: 10px;"></div>
                <input type="hidden" name="tweet_type" id="tweet_type" value="<?php echo $type; ?>" />
                <input type="hidden" name="tweet_offset" id="tweet_offset" value="10" />
                <input type="hidden" name="search_term" id="search_term" value="<?php echo $search_term; ?>" />
                <a id="load_more_buttons" style="text-decoration: none; cursor: pointer; float: right; color: black" onclick="return load_more_tweets();" title="Load more tweets">
                  <img id="loading_animation" src="<?php echo base_url('assets/img/loading_black.gif'); ?>" style="display: none;"/>&nbsp;<b>more</b>&nbsp;<i class="icon-large icon-chevron-down"></i>
                </a>
              <?php } ?>
            <?php } else { ?>
              <div class="item">
                <h4>Oops! No Tweets.</h4>
                <div class="row">
                  <p class="span6">
                    <?php if ($type == 'search') { ?>
                      No results found for '<b><?php echo $search_term; ?></b>'. Try another search term !
                    <?php } else { ?>
                      It will be awesome if you start a new tweet !
                    <?php } ?>
                  </p>
                </div>
              </div>
            <?php } ?>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

